﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Rongzi.Infrastructure.ServiceBus
{
    public interface IMessageQueueProvider
    {
        void Publish<T>(T message, bool durable = true) where T : class;

        /// <summary>
        /// 订阅消息，自动应答
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="subscriptionId">队列ID</param>
        /// <param name="onMessage">消息处理程序</param>
        /// <param name="durable">是否持久化</param>
        /// <returns></returns>
        bool Subscribe<T>(string subscriptionId, Action<T> onMessage, bool durable = true) where T : class;

        /// <summary>
        /// 订阅消息，需要手动应答
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="subscriptionId">队列ID</param>
        /// <param name="handleMessage">消息处理程序，返回是否处理成功</param>
        /// <param name="durable">是否持久化</param>
        bool SubscribeAck<T>(string subscriptionId, Func<T, bool> handleMessage, bool durable = true) where T : class;
    }
}
